{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## numpy 笔记："
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ sum的使用：\n",
    "  + 第一个参数：操作的目标\n",
    "  + axis表示对行/列/维度进行压缩\n",
    "    + 例：axis = 0的话就是对行进行压缩，从上往下压成一行（二维情况）\n",
    "    + 当axis取负数的时候，对于二维矩阵，只能取-1和-2（不可超过矩阵的维度）\n",
    "    + 当axis=-1时，相当于axis=1的效果，当axis=-2时，相当于axis=0的效果\n",
    "    + 如果axis为整数元组（x，y），则是求出axis=x和axis=y情况下得到的和，axis的取值是精确定位某个元素需要经过的数组长度，[CSDN详细解释](https://blog.csdn.net/rifengxxc/article/details/75008427)，个人理解就是axis等于几，就是第几维（第几个\\[\\]\\[\\]中的元素遍历求和，然后在结果中的排布方式是按照除了axis之外的维度的排布）  \n",
    "    ```\n",
    "    >>>np.sum([[0,1],[0,5]],axis=(0,1))\n",
    "    >>>6\n",
    "    >>>np.sum([[0,1],[0,5]],axis=(1,0))\n",
    "    >>>6```\n",
    "   + keepdim是否保持求和后的维度，否则维度会变成(x, )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "def split_hb(totle: int, n: int):\n",
    "    max_space = totle // n\n",
    "    spliter = np.random.randint(0, totle, (1, n - 1))\n",
    "    spliter.sort()\n",
    "    return spliter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1,  4, 19, 46, 50, 62, 64, 84, 86]])"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "split_hb(100, 10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
